import React, { Component } from 'react'
import memoryUtils from '../../utils/memoryUtils'
import {Redirect} from 'react-router-dom'
import { Layout } from 'antd';
import LeftNav from '../../components/left-nav/LeftNav'
import Header from '../../components/header/Header'
import Home from '../home/Home'
import User from '../user/User'
import Category from '../category/Category'
import Product from '../product/Product'
import Role from '../role/Role'
import Bar from '../charts/Bar'
import Line from '../charts/Line'
import Pie from '../charts/Pie'
import { Route,Switch } from 'react-router-dom';



const {Footer, Sider, Content } = Layout;
// 后台管理路由
export default class Admin extends Component {
  render() {
    const user=memoryUtils.user
    console.log(user)
    if(JSON.stringify(user) === "{}"){
      // 自动跳转到登录
      return <Redirect to='/login'/>
    }
    return (
     <Layout style={{height:'100%'}}>
      <Sider>
        <LeftNav/>
      </Sider>
      <Layout>
        <Header/>
        <Content style={{margin:20,backgroundColor:'#fff'}}>
        <Switch>
          <Route path='/home/'  component={Home}/>
          <Route path='/user'   component={User}/>
          <Route path='/category'  component={Category}/>
          <Route path='/product'   component={Product}/>
          <Route path='/role'  component={Role}/>
          <Route path='/bar'  component={Bar}/>
          <Route path='/line'  component={Line}/>
          <Route path='/pie'  component={Pie}/>
          <Redirect to='/home'/>
        </Switch>
        </Content>
        <Footer style={{textAlign:'center',color:'#cccccc'}}>推荐使用谷歌浏览器</Footer>
      </Layout>
    </Layout>
    )
  }
}
